package cn.jsu.oj.dispatchServer.handle;

import cn.jsu.oj.dispatchServer.utils.NetUtil;
import io.netty.channel.Channel;


/**
 * @author ahtonc
 */
public class CommandPack<T> {
    private String ip;
    private String ipAndPort;
    private T data;

    public CommandPack() {
    }

    public CommandPack(String ip, T data) {
        this.ip = ip;
        this.data = data;
    }

    public CommandPack(Channel channel, T data) {
        Object[] ipAndPort = NetUtil.getIpAndPort(channel);
        this.ip = ipAndPort[0].toString();
        this.ipAndPort = ipAndPort[0] + "-" + ipAndPort[1];
        this.data = data;
    }

    public String getIp() {
        return ip;
    }

    public void setIp(String ip) {
        this.ip = ip;
    }

    public String getIpAndPort() {
        return ipAndPort;
    }

    public void setIpAndPort(String ipAndPort) {
        this.ipAndPort = ipAndPort;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    @Override
    public String toString() {
        return "CommandPack{" +
                "ip='" + ip + '\'' +
                ", data=" + data +
                '}';
    }
}
